home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 5
/
The 640 Meg Shareware Studio CD-ROM Volume V (Data Express)(1994).ISO
/
amiga
/
tempdemo.lha
/
ProgrammersInfo
/
InternodeMsgSend.mod.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-22
|
11KB
|
411 lines
/*
[DSKEL-MSg v1.0] MS [Generic] By The Skeleton [08-01-92]
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| NODE | LOGON | HANDLE | ACTiViTY |
|======|=======|===========================|=====================|
| 1 | 17:45 | The Skeleton | Downloading |
|------|-------|---------------------------|---------------------|
| 2 | --:-- | Awaiting a call | Idle |
|------|-------|---------------------------|---------------------|
| 3 | --:-- | Awaiting a call | Idle |
|----------------------------------------------------------------|
| Select node number you want to chat with. |
`----------------------------------------------------------------'
[Return = Quit] Select:
*/
//**********************
//***** Includes *****
//**********************
#include <proto/all.h>
#include <stdio.h>
#include <string.h>
#include <tempest/headers.h>
//********************************
//***** Structures/Defines *****
//********************************
struct MyMessage
{
struct Message Msg;
struct User User;
char text[255],
text1[255];
int car,Value,Data;
long LongValue;
int IntValue;
};
struct User User;
struct MsgPort *MyPort = NULL;
struct MyMessage *msg;
struct node_info nody;
#define DROP if(EXIT_FLAG) CloseStuff();
void CloseStuff(void);
void core(void);
int DOORIO(void);
void Editor(char *,int);
void input(char mstring[],int len);
void pl(char outstring[]);
void sendtext(BYTE);
void WriteFile(char ostring[],char mstring[]);
void ListNodes(void);
int Loadnody(int node);
void Activity(BYTE ,char *);
//*******************************
//***** Global Variables ******
//*******************************
int NODE,R_NODE,NODES;
int EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,
Result,Error,first = 0;
char MyName[255],st[100],DOOR_MSG[255],DOOR_MSG1[255],nodename[255];
//******************
//***** Main *****
//******************
void main(int argc,char *argv[])
{
int stat;
if(!DoorStart(argv[1])) { PutStr("[os2] Tempest Door\n"); exit(0); }
//********************************
//***** Load Internal.Data *****
//********************************
if((!User.NFlags1 & NF1_InternodeMsgSend)||(!User.NFlags1 & NF1_ViewNodeLists))
CloseStuff();
Activity(31,"");
NODE = atoi(argv[1]);
stat=Loadnody(NODE);
if(stat==0)
{
pl("NodeInfo File Not Found!\r\n");
CloseStuff();
}
NODES = nody.SystemDataInfo->NumberOfLines + 1;
core();
CloseStuff();
}
//******************
//***** Core *****
//******************
void core(void)
{
char string[60];
register int x;
int stat;
while(1)
{
REDO:
pl("\r\n
[
Return=Quit
] [L=List Nodes
] [
A=All Nodes
]\r\n");
pl("
Select Node Number you want to send msg to
: ");
input(string,2);
DROP;
if(string[0]==NULL) break;
string[0]=toupper(string[0]);
if((string[0]=='N')||(string[0]=='Q')) break;
R_NODE = 0;
if((string[0]=='?')||(string[0]=='L'))
{
ListNodes();
goto REDO;
}
if(string[0]=='A')
{
stat=0;
for(x=1;x<NODES;x++) if((nody.UserInfo->Name[0]!=NULL)&&(x!=NODE)) stat++;
if(stat>0)
{
sprintf(string,"node:work_ed-A",NODE);
Editor(string,100);
for(x=1;x<NODES;x++)
{
if(x != NODE)
{
stat=Loadnody(x);
if((nody.UserInfo->Name[0]!=NULL)&&(stat!=0))
{
if((*nody.AN!=58)&&(*nody.AN!=56)&&(*nody.AN!=4))
{
R_NODE = x;
if(access(string,0)==0) sendtext(1);
}
}
}
}
DeleteFile(string);
}
else pl("\r\n
Nobody online to send a msg to!\r\n\r\n");
}
x = atoi(string);
if((x==NODE)||(x==0)) goto REDO;
stat=Loadnody(x);
if((nody.UserInfo->Name[0]!=NULL)&&(stat!=0))
{
if(nody.UserInfo->NFlags1 & NF1_RecieveNodeMsgs)
{
if((*nody.AN!=58)&&(*nody.AN!=56)&&(*nody.AN!=4))
{
R_NODE = x;
sprintf(string,"node:work_ed-%d",NODE);
Editor(string,100);
if(access(string,0)==0)
sendtext(0);
}
else pl("\r\n
You can not send a msg to that user at this time!\r\n\r\n");
}
else pl("\r\nSorry, that user is not allowed to receive internode msgs!\r\n\r\n");
}
else pl("\r\nNobody on that node!\r\n");
}
}
//************************
//***** Load Nody ******
//************************
int Loadnody(int node)
{
char string[50];
register int y;
int file;
sprintf(string,"Node:NodeInfo_%d",node);
for(y=1;y<3;y++)
{
file=Open(string,MODE_OLDFILE);
if(file!=0)
{
Read(file,(char *)&nody,sizeof(struct node_info));
Close(file);
return(1);
}
}
return(0);
}
//*************************
//***** List Nodes ******
//*************************
void ListNodes(void)
{
char string[200],string2[20];
char Handle[40],Activity[30],Time[15];
int stat;
register int i;
pl("\r\n
[
Internode Msg Sender Module v2.0
]
By Michael Bockert
[
03-20-94
]\r\n");
pl("
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
\r\n");
pl("
|
NoDE
|
LoGoN
|
HANDLE
|
ACTiViTY
|\r\n");
i=1;
do
{
if(CTRLC())
{
pl("
Aborting Who Display!
\r\n");
return;
}
stat=Loadnody(i);
if(stat==0) setmem(&nody,sizeof(struct node_info),NULL);
strcpy(Handle,nody.UserInfo->Name);
if((*nody.hide==1)&&(User.Security!=255)&&(User.Name[0]!=NULL))
{
if(nody.UserInfo->Slot_Number==1) Handle[0]=NULL;
else strcpy(Handle,"[ Hiding From Display ]");
}
if(Handle[0]!=NULL)
{
sprintf(string,"%s",ctime(&nody.UserInfo->Time_Last_Connect));
strmid(string,Time,12,5);
strcpy(Activity,nody.activity);
sprintf(string,"NODE:CHAT-%d",i);
if(access(string,0)==0) strcpy(Activity,"Chat System");
//***************************
//***** Final Output ******
//***************************
pl("|------|-------|---------------------------|---------------------|\r\n");
// if(nody.NodeDataInfo->LocalMode==0)
sprintf(string2,"%2d",i);
// else strcpy(string2," V");
sprintf(string,"|
%2s
|
%5s
|
%-25.25s
|
%-19s
|\r\n",
string2,Time,Handle,Activity);
pl(string);
}
i++;
}
while(i<NODES);
pl("`----------------------------------------------------------------'\r\n");
}
//***********************
//***** Send Text *****
//***********************
void sendtext(TYPE) // 0 = single, 1 = All
BYTE TYPE;
{
char string[300],shit[100];
char begin[60],middle[60],end[60],send[60];
sprintf(begin,"node:work1-%d",NODE);
if(TYPE) sprintf(middle,"node:work_ed-A",NODE);
else sprintf(middle,"node:work_ed-%d",NODE);
sprintf(end, "node:work2-%d",NODE);
sprintf(send, "node:MsgToNode-%d",R_NODE);
strcpy(shit,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
sprintf(string,"\r\n\r\n
Internode Message
Sent by
%s
on Node #%d\n%s",User.Name,NODE,shit);
WriteFile(begin,string);
sprintf(string,"%s* END OF MSG *\n",shit);
WriteFile(end,string);
sprintf(string,"Join >nil: %s %s %s as %s",begin,middle,end,send);
Execute(string,0L,0L);
DeleteFile(begin);
if(!TYPE) DeleteFile(middle);
DeleteFile(end);
}
//*************************
//***** Close Stuff *****
//*************************
void CloseStuff(void)
{ DOOR_DATA=99; strcpy(DOOR_MSG,'\0'); DOORIO();
while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
if(MyPort) DeletePort(MyPort);
exit(0); }
//********************
//***** DoorIO *****
//********************
int DOORIO(void)
{
struct MsgPort *HisPort;
struct MyMessage message;
int UPDATE;
if(EXIT_FLAG) return 0;
UPDATE=0;
HisPort = FindPort(st);
if(HisPort!=NULL)
{
message.Msg.mn_Node.ln_Type = NT_MESSAGE;
message.Msg.mn_Length = sizeof(message);
message.Msg.mn_ReplyPort = MyPort;
if(first)CopyMem(&User,&message.User,sizeof(struct User));
message.car = 0;
message.Data = DOOR_DATA;
message.Value = DOOR_VALUE;
message.IntValue = DOOR_VALUE1;
strcpy(message.text,DOOR_MSG);
strcpy(message.text1,DOOR_MSG1);
PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
Wait(1 << MyPort->mp_SigBit);
GetMsg(MyPort);
DOOR_DATA = message.Data;
DOOR_VALUE = message.Value;
DOOR_VALUE1 = message.IntValue;
strcpy(DOOR_MSG,message.text);
strcpy(DOOR_MSG1,message.text1);
CopyMem(&message.User,&User,sizeof(struct User));
first=1;
UPDATE=0;
if(message.car) EXIT_FLAG=1;
}
return 0;
}
//************************
//***** Door Start *****
//************************
DoorStart(char node[])
{
struct MsgPort *HisPort;
EXIT_FLAG = 0;
sprintf(st,"%s:TEMPEST_DOOR",node);
HisPort = FindPort(st);
if(HisPort==NULL) return (FALSE);
sprintf(MyName,"%s:DOOR_PORT",node);
MyPort = CreatePort(MyName,0L);
if(MyPort==NULL)
{
PutStr("Cant open port");
return(int)FALSE;
}
DOORIO();
return (int)TRUE;
}
//**********************
//***** Activity *****
//**********************
void Activity(BYTE act,char *text)
{ DOOR_DATA=72; DOOR_VALUE=act; strcpy(DOOR_MSG,text); DOORIO(); }
//********************
//***** Editor *****
//********************
void Editor(char Filename[],int value)
{ DOOR_DATA=29; DOOR_VALUE=value; strcpy(DOOR_MSG,Filename); DOORIO(); }
//*******************
//***** Input *****
//*******************
void input(char mstring[],int len)
{ DOOR_DATA=40; DOOR_VALUE=len; strcpy(DOOR_MSG,mstring); DOORIO();
strcpy(mstring,DOOR_MSG); strcpy(DOOR_MSG,'\0'); strcpy(DOOR_MSG1,'\0'); }
//*****************************
//***** PL (Print Line) *****
//*****************************
void pl(char outstring[])
{ DOOR_DATA=1; strcpy(DOOR_MSG,outstring); DOORIO(); }
//************************
//***** Write File *****
//************************
void WriteFile(char ostring[],char mstring[])
{ DOOR_DATA=16; strcpy(DOOR_MSG,ostring); strcpy(DOOR_MSG1,mstring); DOORIO();
strcpy(DOOR_MSG,'\0'); strcpy(DOOR_MSG1,'\0'); }
//*************************
//***** CTRLC CHECK *****
//*************************
int CTRLC(void)
{
DOOR_DATA=73;
DOORIO();
return(DOOR_VALUE);
}